#!/bin/bash
echo -n "Enter your salt (won't be displayed): "
read -s SALT
echo -en "\n"

#echo -n "Confirm: "
#read -s SALT_CONFIRM
#echo -en "\n"
#if [ $SALT != $SALT_CONFIRM ]; then
#        echo "Confirm did not match. Program ending."
#        exit 1;
#fi

echo -n "Enter your string: "
read STRING
#echo -n "Confirm: "
#read STRING_CONFIRM
#if [ $STRING != $STRING_CONFIRM ]; then
#        echo "Confirm did not match. Program ending."
#        exit 1;
#fi
PASSWORD=$(echo -n "$SALT$STRING" | sha512sum | base64 -w 0)

# Color the password output as black (assuming terminal background 
# is black) to avoid cameras/shoulder surfers seeing your password.
# For other colors use the other ANSI escape codes:
#	Black        0;30     Dark Gray     1;30
#	Red          0;31     Light Red     1;31
#	Green        0;32     Light Green   1;32
#	Brown/Orange 0;33     Yellow        1;33
#	Blue         0;34     Light Blue    1;34
#	Purple       0;35     Light Purple  1;35
#	Cyan         0;36     Light Cyan    1;36
#	Light Gray   0;37     White         1;37
#	no color     0
echo -n "Your password is: "
echo -e "\033[0;30m${PASSWORD:0:32}\033[0m"
exit 0;
